/**
 * 
 */
package ac.notification.manager;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author Ankush Chaudhary
 *
 */
public class NotificationManagerFactory
{
	Map<String,INotificationManager> notifiersPoolMap;
	private static NotificationManagerFactory notificationManagerFactory;
	private NotificationManagerFactory()
	{
		notifiersPoolMap = new HashMap<String, INotificationManager>();
	} 
	
	//Getter setter through which pool of notifiers are accessed.
	public static NotificationManagerFactory getNotificationManagerFactory() {
		if(null == notificationManagerFactory)
		{
			notificationManagerFactory = new NotificationManagerFactory();
		}
		return notificationManagerFactory;
	}
	public static void setNotificationManagerFactory(NotificationManagerFactory notifiersPool) {
		NotificationManagerFactory.notificationManagerFactory = notifiersPool;
	}
	
	//Method to create a custom notification manager and return same.
	
	public String createDefaultNotificationManager(String notificationManagerIdentifier)
	{
		String noMaId = notificationManagerIdentifier.toUpperCase();
		INotificationManager notificationManager = new DefaultNotificationManager();
		getNotificationManagerFactory().notifiersPoolMap.put(noMaId, notificationManager);
		return noMaId;
	}
	
	
	public String createCustomNotificationManager(String notMgrId,INotificationManager notificationManager)
	{
		String noMaId = notMgrId.toUpperCase();
		getNotificationManagerFactory().notifiersPoolMap.put(noMaId, notificationManager);
		return noMaId;
	}
	
	public INotificationManager getNotificationManager(String notificationManagerId)
	{
		return getNotificationManagerFactory().notifiersPoolMap.get(notificationManagerId);
	}
	
	public Set<String> getAvailableNotificationManagerNames()
	{
		return getNotificationManagerFactory().notifiersPoolMap.keySet();
	}

}
